'use strict';
const base = require('../base/serviceBase');
const _ = require('lodash');
const moment = require('moment');
const { result } = require('lodash');
const table = 'Customer';
module.exports = class extends base {
  async create(body) {
    const { ctx } = this;
    const result = await ctx.app.dbs.insert('DeliverChannel', body);
    console.log('create deliver channel',result);
    return { status: 'ok', result };
  }

  async findDetail(body) {
    const { ctx, service } = this;
    const { shippingMan, tenantCode } = body;
    const list = await ctx.app.dbs.find('DeliverChannel', { shippingMan, tenantCode });
    let fee = 0;
    _.map(list, (item) => {
      const { shippingFee = 0 } = item;
      fee += shippingFee;
    });
    return { status: 'ok', result: { fee, list } };
  }
};
